perm filename ALS15[F8,ALS] blob
sn#300825 filedate 1977-08-16 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 *CHECKERS REV 0.12
C00077 ENDMK
Cā;
*CHECKERS REV 0.12
* DATE 8/12/77 VERSION ALS
*
*Resident package addresses
JOYT EQU H'0C00'
LINE EQU H'0FDF'
SHCB EQU H'0FE2'
INPF EQU H'0FE3'
WTLN EQU H'0FE5'
TXC EQU H'0FE8'
CMRG EQU H'0FEA'
DBNC EQU H'0FEB'
UPI EQU H'0FFA'
*JOYI EQU H'21C4' Using internal copy
IJS EQU H'22DC'
PUSH EQU H'4097'
POPS EQU H'40AA'
SPS EQU H'40BE'
WMS EQU H'41FD'
UDAT EQU H'4245'
FCS EQU H'43BE'
WAIT EQU H'44E9'
TIR EQU H'45C3'
*Misc. constants
TCMD EQU H'44'
BCMD EQU H'6D'
TCOL EQU H'80' TEXT COLOR
ULIN EQU H'E5'
COM EQU H'8F7'
SLT EQU SKL
*
*RAM assignments
JOYK EQU H'0B23' 0 if JOY, FF if KEYBOARD
OBJ0 EQU H'C30'
TREE EQU H'0E10' Tree data (15 blocks of 16 bytes each)
BLCK EQU H'0E10'
RED EQU H'0E20'
JSAV EQU H'0E50' Temp store of Joystick readings
PLMD EQU H'0EC0' Used for temp store of player's move info
PLMV EQU H'0ED0' Overlay region used for player's moves
PLMF EQU H'0EE0' and move numbers
MOBS EQU H'0F00' Mobility and DJ flags (14 bytes)
PLY0 EQU H'0F0E' Place for player's ply depth choice
COL0 EQU H'0F0F' Place for color choice (next after PLY0)
OBJ1 EQU H'F10' BOARD 2
*
*Scratch pad assignments
J EQU H'9'
HU EQU H'A'
HL EQU H'B'
PLOC EQU O'3' LISU value for ACTIVE and PASSIVE
KLOC EQU O'4' LISU value for KING's and special data
ELOC EQU O'5' LISU value for EMPTY's area
ISA EQU O'30' ISAR value for active area
ISP EQU O'34' ISAR value for passive
ISK EQU O'40' ISAR value for kings
ISE EQU O'51' ISAR value for empty (with offset)
*Mimimum ply depths
PLYT EQU H'FE' Ply depth for Robot Tom (stored as neg.)
PLYD EQU H'FD' Ply depth for Robot Dick
PLYH EQU H'FC' Ply depth for Robot Harry
*
ORG H'1000'
DC H'AA'
DC H'55'
DC H'00' BACKGROUND COLOR
DC H'00' BACKGROUND COLOR
DC H'00' SPACES
DC H'00' SPACES
DC H'3119' CH
DC H'0B31' EC
DC H'150B' KE
DC H'0921' RS
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
*
* MAIN PROGRAM STARTS HERE
*
PI SPS
*
* SET INTERRUPT VECTOR
*
* SET LINE INTERRUPT
*
DI DISABLE INTRPT
*This code for compilers that accept : and .
LI INHR: Set INT vector in SMI
OUTS H'C'
LI INHR.
*This code for compilers that do not accept : and .
* DCI INHR
* LR Q,DC
* LR A,QU
* OUTS H'C'
* LR A,QL
*End of substitution
OUTS H'D'
LIS H'0'
OUTS H'E' Disable SMI INT
*First question to define skill level
PI TINT TEXT INIT
LISU O'2'
LISL O'4'
LI H'40' H40=D64
LR S,A SET REG24
DCI LINE
LI H'20' LINE # 2 POS. 0
ST
DCI SKL SKILL LEVEL TABLE
PI WMS WRITE MESSAGE
PI RKB READ KEYBOARD
CI H'1F' IS IT DICK?
BNZ QN12 No
LI PLYD
BR QN14
QN12 CI H'19' IS IT HARRY?
BNZ QN13 No, it must be Tom
LI PLYH
BR QN14
QN13 LI PLYT
QN14 DCI PLY0
ST
*Second question joystick vs keyboard
PI TINT INIT.TEXT
LISU O'2'
LISL O'4' SET ISAR
LI H'30' #OF CHARS.
LR S,A PUT IT IN '24'
DCI LINE
LI H'30' LINE 3 POS.0
ST
DCI INJK TEXT TABLE ADDR.
PI WMS
PI RKB READ KEYBOARD
CI H'15' IS IT K?
LIS H'F' F if keyboard
BZ INJ It is K
*Note the next instruction seems to take enough time to cause timing
*troubles with the next question.
* PI IJS Init joystick
CLR 0 if joystick
INJ DCI JOYK
ST
*Third question play black or red
PI TINT TXT INIT
LISU O'2'
LISL O'4'
LI H'1A' H1A=D CHARS.
LR S,A PUT IT IN 24
DCI LINE
LI H'30'
ST
DCI YMF
PI WMS
PI RKB GET ANSWER FROM KBD
CI H'2B' IS IT 'N'?
CLR
DCI COL0
BZ QN31 ITS N
ST
DCI BLCK DEF. BLACK
BR QN32
QN31 COM
ST
DCI RED
QN32 LR H,DC PUT IT IN H
**** FIX NEEDED HERE
*IF ANSWER IS N WE WILL HAVE TO JMP TO ANOTHER LOCATION
*Now set up board
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
PI BRDI Set up initial board
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DCI JOYK
LM
NI H'FF'
BNZ PLMC
PI IJS
DCI JSAV Initialize for first read of joystick
LIS H'F' Anything greater than 7
ST
ST
*Get available black moves from table BLKM
PLMC DCI PLMV
XDC
DCI BLKM
LIS H'6'
LR 0,A
PLML LM
XDC
ST
XDC
DS 0
BP PLML
****PUT CODE HERE TO TELL PLAYER THAT IT IS TIME FOR HIM TO MOVE
CUR1 PI CURS Follow cursor to identify piece
NOP We'll need time to check piece
NOP
NOP
NOP
DI Disable CPU interrupt
* DCI CMRG Reset INT bit in COM reg
* LR Q,DC
* LM
* OI H'21'
* NI H'F7'
* LR DC,Q
* ST
* DCI COM
* ST
* EI
NOP
NOP
NOP
NOP
*This code for compilers that accept : and .
LI INHR: Set INT vector in SMI
OUTS H'C'
LI INHR.
*This code for compilers that do not accept : and .
* DCI INHR
* LR Q,DC
* LR A,QU
* OUTS H'C'
* LR A,QL
*End of substitution
OUTS H'D'
LI ULIN Set Y INT reg to E5
DCI H'8F0'
ST
LIS H'08' Set INT bit in COM reg
DCI CMRG
LR Q,DC
OM
LR DC,Q
ST
DCI COM
ST
LIS 1
OUTS H'E' Enable SMI INT
EI Enable CPU INT
BR * TEST LOOP FOR ABOVE
JMP OKPI
OKNO CLR Clear 3 to show that piece cannot move
LR 3,A
*We will now have to signal that he has picked a piece that can move but
*it can not move to the square chosen and that the player is to try again
****PUT CODE HERE TO TELL PLAYER THAT PIECE CANNOT MOVE AND TO TRY AGAIN
*We will want th indicate failure, perhaps by a growl before going back
*to letting the player try to find a piece that can move
BR CUR1
* Code to verify that indicated piece can, in fact, move.
* The byte showing the piece is in 3 and the byte # is in 4 without
* the jump bit and the direction as yet.
OKPI DCI PLMV Possible moves listing
LM Number of entries here
ADC
CLR
ST Set zero to stop search
DCI PLMV
LM Skip the number of entries
OKP1 LM Get first move byte
NI H'FF'
BZ OKNO No more entries
NS 3
BNZ OKP2 This might be the one
CM A cheap way to index
BR OKP1 Try again
OKP2 LM Next entry is the byte info
NI H'0C' Remove the J bit and the direction
XS 4 Does it match?
BNZ OKP1 Try again
LR Q,DC
XDC Save data position
DCI PLMD Save data as to starting square
LR A,QU So we can use Q freely if need be
ST
LR A,QL
ST
LR A,1
ST Save the normalized X position
LR A,2
ST and the normalized Y position
LR A,3
ST Save player's starting byte
LR A,4
ST and the Byte number
*We may want to signal the success by some audible signal
LR A,0
*Similar code to test destination goes in here
CUR2 PI CURS Follow cursor to identify destination
NOP We'll need time to check move
NOP
NOP
NOP
BR *
*This code for compilers that accept : and .
LI INHR: Set INT vector in SMI
OUTS H'C'
LI INHR.
*This code for compilers that do not accept : and .
* DCI INHR
* LR Q,DC
* LR A,QU
* OUTS H'C'
* LR A,QL
*End of substitution
OUTS H'D'
LI ULIN Set Y INT reg to E5
DCI H'8F0'
ST
LIS H'08' Set INT bit in COM reg
DCI CMRG
LR Q,DC
OM
LR DC,Q
ST
DCI COM
ST
LIS 1
OUTS H'E' Enable SMI INT
EI Enable CPU INT
*Now test indicated move for legality
OKMV DCI PLMD
LM
LR QU,A
LM
LR QL,A
LM Get the old X value
COM
INC
AS 1 This gives us the change in X
LR 5,A
LM Get the old Y value
COM
INC
AS 2
LR 6,A
BM OKM4
CI H'01'
BZ OKM2 It was a normal forward move
CI H'02'
BNZ NONO Not a legal move
LR A,5
CI H'02'
BNZ OKM1
LI H'10' A RFJ move
BR OKN Still must make sure
OKM1 CI H'FE'
BNZ NONO
LI H'11' A LFJ move
BR OKN
OKM2 LR A,5
CI H'01'
BNZ OKM3
CLR A RFN move
BR OKN
OKM3 CI H'FF'
BNZ NONO
LIS H'01' A LFN move
BR OKN
OKM4 CI H'FF'
BZ OKM6
CI H'FE'
BNZ NONO
LR A,5
CI H'02'
BNZ OKM5
LI H'12' A RBJ jump
BR OKN
OKM5 CI H'FE'
BNZ NONO
LI H'13' A LBJ jump
BR OKN
OKM6 LR A,5
CI H'01'
BNZ OKM7
LI H'01' A RBN move
BR OKN
OKM7 CI H'FF'
BNZ NONO
LI H'11' A LBN move
OKN AS 4 Add the byte number
LR 4,A and save the complete byte info
LI H'FF' Back up
ADC
OKN2 LR A,4
CM Is it the same?
BZ OKOK Found!
OKN3 LM Go to the next entry
NI H'FF'
BZ NONO
NS 3
BNZ OKN2 A bit matches here
CM A cheap way to index
BR OKN3
*Player has selected an impossible destination
NONO NOP
DCI PLY0
LM
CI PLYT
BZ NON2
****PUT MESSAGE HERE THAT DESTINATION IS IMPOSSIBLE AND TO TRY AGAIN
****NOTE THAT WHEN PLAYING DICK OR HARRY THE PLAYER MUST MOVE A PIECE THAT
****CAN MOVE, ONCE HE HAS TOUCHED IT
JMP CUR2
NON2 NOP
****PUT CODE HERE GIVING TOM PLAYERS THE CHOICE OF SELECTING A DIFFERENT PIECE
****IF HE WANTS TO DO THIS ELSE HE MAY SIMPLY SELECT A DIFFERENT DESTINATION
JMP CUR1
OKOK NOP
**** ACKNOWLEDGE ACCEPTABLE MOVE HERE
*Remove cursor
DCI JSAV
LM
LR 1,A
LM
LR 4,A
PI MAPS This removes cursor
*Move piece
*Tree routine goes in here
*On completion of tree search we compute all of the possible moves for
*the player and store them at PLMV before making the move and signalling
*the player that it is now his move, and return to CUR1
JMP CUR1
*
*
*
*
*Subroutine to find square indicated by cursor
CURS LR K,P
PI PUSH
LI H'E5'
DCI WTLN
ST
NOP
NOP
NOP
NOP
PI MAP
NOP
NOP
NOP
NOP
OUTS 1
CLR Read push button
INS 1
NI 1
BZ CURS Loop until button is pushed
PI POPS
PK
* TINT TEXT INITIALIZATION
TINT LR K,P SAVE RETURN
PI PUSH
PI RST RESET UM1 REGS.
TNT1 DCI H'8FB'
LIS H'8'
XM
BNZ TNT1
DCI CMRG PROG COPY OF COM REG.
LI TCMD DISPLAY COMMAND
ST
DCI H'C18'
CLR
ST
DCI WTLN
LI ULIN WAIT LINE
ST
DCI TXC TEXTCOLOR
LI TCOL
ST
PI TIR CALL TEXT INIT
PI POPS
PK
*
**********************************************************
*
* RST RESETS UM1 REGS.
*
**********************************************************
RST LR K,P CLR R/W REGS.
LI H'80'
LR 0,A
LI H'FF'
DCI H'800'
RST1 ST
DS 0
BNZ RST1
DCI H'8F0' CLR WRITE ONLY REGS
LIS H'8'
LR 0,A
CLR
RST2 ST
DS 0
BNZ RST2
PK
*
**************************************************************
*
* KEYBORD READ
*
**************************************************************
RKB LR K,P
PI PUSH
CLR
DCI INPF CLEAR FLAG
ST
DCI DBNC
ST
DCI SHCB CLER SHIFT CONTROL
ST
DCI CMRG
LI TCMD
ST
LISU O'2'
LISL O'4'
LI H'C0' WAIT TIME FOR FCS
LR S,A PUT IT IN '24'
RKB1 PI FCS GET CHAR.
BZ RKB1 WAIT FOR ANY KEY
LR A,8 RETURN CHAR IN AC
PI POPS
PK
*
************************************************************************
*
* BOARD IMAGE ROUTINE
*
******************************************
*
BRDI LR K,P SAVE RETURN
NOP
NOP
NOP
PI PUSH
PI RST RESET UM1 REG
PI BORD GENERATE BOARD
PI SURP SET UM1 REGS AND POINTERS
*
*Put in initial pieces both in SC and in blocks 0 or 1
LISU PLOC
LISL H'0'
LI H'FF' Full double row of pieces
LR I,A First byte of ACTIVE
LI H'F0' 1 row only
LR I,A Second byte of active
CLR
LR I,A Part of board with no active pieces
LR I,A Part of board with no active pieces
LR I,A Part of board with no passive pieces
LR I,A Part of board with no passive pieces
LI H'F' 1 row only (in second half of byte)
LR I,A byte of PASSIVE
LI H'FF' Full double row of pieces
LR I,A Last byte with Passive pieces
LISU KLOC
LISL 0
CLR
LR I,A 4 king bytes next (all empty)
LR I,A
LR I,A
LR I,A
LI H'F0' The 4 bits for pieces that can move RF
LR I,A The MOVE byte
LIS H'4' BYTE # 1 RF normal move with no piece debit
LR I,A
LI H'80' Set score at -128 (lose, unless move is found)
LR I,A
CLR With position advantage of 0
LR I,A
* LR DC,H This was set earlier
* PI SCRD Store pieces in correct RAM pos.
* LR DC,H
CLR Should put black at bottom
COM Should put red at bottom
DCI COL0
ST
PI MEN
* A DUMMY LINE TO FIX AN ASSEMBLY ERROR
PI POPS
PK
* Code to read the internal representation of the board and to put the
* required pieces into the board image.
*
MEN LISU O'3' Start with pieces
LIS H'1' 1 for red pieces (shown first always)
LR 4,A To specify piece color (1 red, 0 black, -1 king)
XDC
DCI COL0
LM
XDC
LR 7,A
LR A,11
SR 4
AI H'FF'
LR A,7
BZ *+2
COM
LR 7,A
NS 7 Set status
LISL O'7' Decrement if black is active and shift right
BZ MEN1 Black is active (Appears at bottom of screen)
LISL O'0' Red is active, increment and shift left
MEN1 LIS H'3'
LR 1,A To count bytes
MEN2 LR K,P
LIS H'7'
LR 2,A To count bits
DCI TAB1 STARTING ADDRESS FOR BYTE LOCATION
LR A,1 This byte number
SL 1 Locations occupy 2 bytes each
ADC
LM Get the location
LR QU,A and save it in Q
LM
LR QL,A
LR A,7
NS 7
BZ MEN5 Black is active
LR A,I Increment if red is active
BR MEN4
MEN3 LR A,3
SL 1 and shift left
MEN4 LR 3,A
NI H'80' (done this way for symetry, BC would work)
BZ MEN9
BR MEN8
MEN5 LR A,D Decrement if black is active
BR MEN7
MEN6 LR A,3
SR 1 and shift right
MEN7 LR 3,A
NI H'1'
BZ MEN9
MEN8 DCI TAB2 Relative-locations-of-squares table
LR A,2 This square
ADC
LM Get square displacement
LR DC,Q Recall the location for the input byte
ADC This is the square position
LR A,4 Identify type of piece
NS 4
BM PUTK To put down a king
LIS H'4' Prepare for a piece
LR 5,A To count lines
LI H'20' Skip the first 4 lines (4*8)
ADC
XDC
DCI BLKP Anticipate a black piece
BZ PUTL A black piece (status bit still ok)
DCI REDP No, it's a red piece
BR PUTL
PUTK LIS H'2' Only 3 lines for a crown
LR 5,A
LIS H'8' To skip 1 line
ADC
XDC
DCI KING
PUTL LM Put loop
XDC
ST
LIS H'7' To next line on screen (less increment)
ADC
XDC
DS 5
BP PUTL Loop
MEN9 DS 2
BM ME10
LR A,7
NS 7
BZ MEN6 Black active case
BR MEN3 Red active case
ME10 DS 1
BP MEN2 For the next input byte
LR A,4
NS 4
BM BDEX Exit from board routine
DS 4
BP MEN1 Go round again for black pieces
LISU H'4' Get set for kings
LR A,7
NS 7
LISL H'3' Decrementing case
BZ MEN1
LISL H'0' Incrementing case
BR MEN1
BDEX PK
*
***********************************************************************
*
* BORD GENERATES BOARD IMAGE
*
************************************************************************
*
BORD LR K,P
PI PUSH
LI H'FF'
LR 3,A REG3=FF
DCI OBJ0 BRD1 START ADDRESS
LIS H'2' FLAG FOR BORD
LR 4,A SET REG 4 = 2
LIS H'6'
BRD4 LR 0,A REG0 = 6 ROWS
BRD3 LIS H'A'
LR 1,A REG 1 = 10 LINE/ROW
BRD2 LIS H'4'
LR 2,A REG2=SQ PAIRS/ROW
BRD1 LR A,3
ST STORE IN BRD
COM
ST NEXT IS COMPL. OF FIRST
DS 2
BNZ BRD1 MORE FOR THIS ROW
DS 1 NO, ALL LINE DONE
BNZ BRD2
LR A,3 DONE A TIMES YET
COM
LR 3,A
DS 0 DEC ROW COUNT
BNZ BRD3 ALL ROWS DONE?
DS 4
BZ BRD5 BOTH OBJECTS DONE?
DCI OBJ1 NO,GET BORD2 ADDRS.
LIS H'2'
BR BRD4 REG0=2
BRD5 PI POPS
PK
***********************************************************************
*
* SURP SETS UM1 REGS & PTRS
*
***********************************************************************
SURP LR K,P
PI PUSH
DCI H'800' UM1 REG START
XDC TUCK IT AWAY
DCI INIT INIT TABLE POINTER
LIS H'6'
LR 0,A
SRP1 LM READ INIT TABLE
XDC
ST PUT IN UM1
XDC PT. BACK TO INIT
LM READ TABLE
XDC
ST
DS 0 REG 0 = COUNTER 6
BZ SRP2
LIS H'E'
ADC
XDC
BR SRP1 CONTINUE
SRP2 LI H'1E' DO LAST TWO ENTRIES
ADC
XDC
LM GET IT FROM INIT TAB
XDC
ST PUT IT UM1
XDC
LM GET IT FROM
XDC
ST
*
* SET UPI PTRS
*
DCI UDIT
LR Q,DC
DCI UPI
LIS H'2'
ST
ST
LR A,QU
ST
LR A,QL
ST ODD
LR A,QU
ST
LR A,QL
ST
PI POPS
PK
*
* Subroutine to move data from RAM to S O'30' thru O'47' with the data for
* S O'30' thru O'43' coming from the current block. Data for O '44' thru
* O'47' is from the previous block, with some items deleted.
*
RASC LR K,P Save return address
PI PUSH
LISU PLOC SC buffer with Active and Passive
LISL 0
LIS H'8'
LR 0,A
PI RASL
LISU KLOC SC buffer with Kings
LISL 0
LIS H'4'
LR 0,A
PI RASL
LI H'F1' Rest of data from earlier block
ADC
CLR Zero the MOVE byte
LR I,A
LM
NI H'E0' Save Piece debit only
LR I,A
LM
LR I,A Keep both SCORE bytes
LM
LR I,A
PI POPS
PK
*
RASL LR K,P
RAS2 LM
LR I,A
DS 0
BNZ RAS2
PK
*
*Subroutine to move 16 bytes from SC O'30' thru O'47' to RAM direct.
SCRD LR K,P
PI PUSH
LISU PLOC
LISL 0
LIS H'8'
LR 0,A
PI SCRL
LISU KLOC
LISL 0
LIS H'8'
LR 0,A
PI SCRL
PI POPS
PK
*
*Subroutine to move 16 bytes from SC O'30' thru O'47' to RAM, reversing
*ACTIVE and PASSIVE and deleting some items
SCRA LR K,P
PI PUSH
LISU PLOC
LISL 4
LIS H'4'
LR 0,A
PI SCRL
LISL 0
LIS H'4'
LR 0,A
PI SCRL
LISU KLOC
LISL 0
LIS H'4'
LR 0,A
PI SCRL
LR A,I To index only
CLR Zero MOVE byte
ST
LR A,I
NI H'E0' Save piece debit only
LR A,I
ST Save both SCORE bytes
LR A,I
ST
PI POPS
PK
*
SCRL LR K,P
SCR3 LR A,I
ST
DS 0
BNZ SCR3
PK
*
*To compute 4 bytes which show the empty squares on the board and store
*them in O'51' thru O'54' with O'50' and O'55' set to zero as guards.
*Note especially that the EMPTY locations are displaced relative to ACTIVE.
EMPTY LR K,P
LISU ELOC
LISL 0
CLR
LR S,A Make sure guard byte is empty
LISU PLOC Start with ACTIVE
LIS H'4'
LR 0,A
BR EMP3
EMP2 LR A,IS
AI H'30' Actually subtracting 16
LR IS,A
EMP3 LR A,S
LR 1,A
LR A,IS
AI 4
LR IS,A
LR A,S
AS 1
LR 1,A
LR A,IS
AI H'D' Add 13 to get to the correct EMPTY location
LR IS,A
LR A,1
COM Reverse 1's and 0's
LR S,A
DS 0
BNZ EMP2
CLR
LR S,A Upper guard byte
PK
*
*Subroutine to count bits in 0 and return count in A
*Uses registers 0 and 1
CAQ LR K,P
CLR
LR 1,A
LR A,0
BR CAQ3
CAQ2 DS 1
AI H'FF'
NS 0
LR 0,A
CAQ3 BNZ CAQ2
LR A,1
COM
INC Make it into a true positive number
PK
*
*Subroutine to multiply 2 positive binary numbers (the smaller in SC 1 and
*the larger in SC 2) by Russian multiplication. SC 0 is used to accumulate
*the product. This code may be used at only one place and can probably be
*written in line at that place with some saving of space.
*
MPYR LR K,P
CLR
LR 0,A To accumulate the product
LR A,1
MPY1 NI H'1' Is the rightmost bit a 1?
BZ MPY2 No
LR A,2
AS 0
LR 0,A
MPY2 LR A,2
SL 1
LR 2,A
LR A,1
SR 1
LR 1,A
BNZ MPY1 Product is not complete
PK
*MAP Code to convert joystick reading into cursor position on board.
*Cursor's position on the board image is limited to the playing squares.
*When the joystick is moved the cursor jumps from playing square to
*playing square, always landing on that square that is nearest to the
*indicated joystick position.
*
*Interrogates JOYI twice to get X and Y readings of joystick position.
*Returns byte in 3 (with one bit on for square) and byte number in 4 and
*moves cursor from old position on board image to new position.
*Uses reg 0, 1, 2, 3, 4, H, Q, and DC.
MAP LR K,P
PI PUSH
LIS H'01' GET X
LR HU,A
NOP
NOP
NOP
NOP
DI
DCI COM
LI H'65'
ST
DCI CMRG
ST
LI H'30'
PI WAIT
PI JOYI
LR 0,A
NOP
NOP
NOP
NOP
PI MAPA
LR A,0
LR 1,A
CLR
LR HU,A
NOP
NOP
NOP
NOP
PI JOYI
LR 0,A
NOP
NOP
NOP
NOP
*This code for compilers that accept : and .
LI INHR: Set INT vector in SMI
OUTS H'C'
LI INHR.
*This code for compilers that do not accept : and .
* DCI INHR
* LR Q,DC
* LR A,QU
* OUTS H'C'
* LR A,QL
*End of substitution
OUTS H'D'
LIS H'1'
DCI COM
LI BCMD
ST
DCI CMRG
ST
EI
NOP
NOP
NOP
NOP
PI MAPA
LR A,0
LR 2,A
AS 1
LR 3,A Unnormalized sum in 3
LIS H'8'
LR 0,A
LR A,3
MAP2 DS 0
AI H'F9' Sub 7
BP MAP2
LR A,0
LR 3,A Sum into 3, range 0 thru 6
LR A,1
COM
AI D'25'
AS 2
LR 4,A Unnormalized difference in 4
LIS H'9' Need 8 catagories for the difference
LR 0,A
LR A,4
MAP3 DS 0
AI H'FD' Sub 3
BP MAP3
LR A,0
LR 4,A Difference into 4, range 0 thru 7
COM
INC
AS 3
INC
LR 1,A Normalized X value
LR A,4
AS 3
INC
SR 1
LR 2,A Normalized Y value
SR 1
LR 4,A The byte number left in 4
LR A,1
SR 1
INC
LR 3,A
LIS H'8'
BR MAP5
MAP4 SR 1
MAP5 DS 3
BNZ MAP4
LR A,1
NI H'1'
BNZ MAP6
LR A,3
SR 4
LR 3,A
MAP6 NOP Byte with bit on left in 3
LR A,1
SR 1
LR 1,A
LR A,2
NI H'1'
BZ MAP7
LR A,1
AI H'4'
LR 1,A This is now the offset in the byte
MAP7 NOP
DCI JSAV
LR Q,DC
CM
BZ MAPX No change in position so exit
*Now we want to remove the old cursor and write the new
PI MAPS Write new cursor
DCI JSAV
LR Q,DC
LM
LR 0,A
LR A,1
LR DC,Q
ST Save new value
LR A,0
LR 1,A Get ready to delete old cursor
LR Q,DC
LM
LR 0,A
LR A,4
LR DC,Q
ST
LR A,0
LR 4,A
CI H'07'
BM MAPX No old cursor to remove
PI MAPS
MAPX PI POPS
PK
*Subroutine to complement cursor (to remove old one or write new one)
MAPS LR K,P
DCI TAB1
LR A,4
SL 1
ADC
LM
LR QU,A
LM
LR QL,A
LIS H'4'
LR 5,A
DCI TAB2
LR A,1
ADC
LM
LR DC,Q
ADC
XDC
DCI POIN
PUTP LM
XDC
LR Q,DC
XM Compliment POIN
LR DC,Q
ST
LIS H'7'
ADC
XDC
DS 5
BP PUTP
PK
*
*Subroutine to reduce range and invert if necessary
MAPA LR K,P
LR A,0
SR 1
SR 1
SR 1
LR 0,A
LR A,7 Check color
NS 7
BNZ MAPB Do we need to invert?
LR A,0
COM
AI D'25'
LR 0,A
MAPB PK
*
*
*
ORG H'17C0'
* INHR INTERRUPT HANDLER
*
* WILL STORE ENVIRONMENT BEFORE CALLING UDAT
* AND RESTORE BEFORE GOING BACK'
*
INHR LR 6,A SAVE ACC
LR A,IS
LISU O'6'
LISL O'0'
LR I,A SAVE A IN REG24
LR A,QU
LR I,A SAVE QU IN REG25
LR A,QL
LR I,A SAVE QL IN REG26
LR A,J
LR I,A SAV IN REG27
XDC
LR Q,DC GET DC
DCI H'0FB0' GET FREE RAM ADDR.
LR A,QU SAVE ORIGINAL DC1
ST
LR A,QL
ST
XDC
LR Q,DC
XDC
LR A,KU
ST
LR A,KL
ST SAVE KL
LR A,10 UPPER H
ST SAVE IT
LR A,11
ST SAVE H
LR J,W
LR A,J
ST SAVE W
LR K,P
LR A,KU
ST SAVE PCU
LR A,KL
ST SAVE PCL
LR A,QU SAVE DC0 ORIGINAL
ST
LR A,QL
ST
PI UDAT UPTE DISPLAY
*
* RESTORE ALL REGISTERS
*
DCI H'0FB0'
LM
LR QU,A GET DC1
LM
LR QL,A
XDC
LR DC,Q RESTORE DC1
XDC
LIS H'2'
ADC BYPASS 'K' SAVED AREA
LM GET HU
LR HU,A RESTORE HU
LM
LR HL,A RESTORE HL
LM GET W
LR J,A
LR W,J RESTORE IT
LM GET PC1 HO
LR KU,A
LM
LR KL,A
LR P,K RESTORE PC1
LM
LR QU,A
LM
LR QL,A
DCI H'FB2' PT TO K
LM GET KU
LR KU,A
LM
LR KL,A RESTORE K
LR DC,Q RESTORE DC0
*
* NOW RESTORE J,Q,A FROM SCRATCH PAD
*
LISU O'6'
LISL O'3'
LR A,D GET J
LR J,A
LR A,D GET QL
LR QL,A
LR A,D
LR QU,A RESTORE QU
LR A,D GET ISAR
LR IS,A RESTORE ISAR
LR A,6 RESTORE A
EI INT. ENABLE
POP
* DISPALY YOU MOVE FIRST?
* Y OR N
*
*
YMF DC H'0513' Y0
DC H'0300' U-
DC H'2913' MO
DC H'2F0B' VE
DC H'00' -
DC H'1D' F
DC H'0109' IR
DC H'2107' ST
DC H'00' -
DC H'35' ?
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'0500' Y-
DC H'1309' OR
DC H'00' -
DC H'2B' N
* INIT DATA
INIT DC H'30' OBJ0 L.O.RP
DC H'10' OBJ1 L.O. RP
DC H'8C' OBJ0 H.O.RP+COLOR
DC H'8F' OBJ1 H.O.RP
DC H'48' OBJ0 DELTA X ---
DC H'48' OBJ1 DELTA X---
TY0 DC H'3C' OBJ0 DELTA Y ----
DC H'14' OBJ1 DELTA Y ---
DC H'0D' OBJ0-X-CO
DC H'0D' OBJ1 X-CO
DC H'47' OBJ0 Y-VALUE L.O.A
DC H'BE' OBJ1 Y-VALUE L.O.A
DC H'00' OBJ0 Y-VALUE H.0 &X-ORDER
DC H'01' OBJ1- Y-VAL H.O.$X-ORDER
*A DUMMY LINE TO FIX AN ASSEMBLY ERROR
UDIT DC H'30'
DC H'10'
DC H'8C'
DC H'8F'
DC H'3C'
DC H'14'
TAB1 DC H'0F10' BYTE 3
DC H'0D70' BYTE 2
DC H'0CD0' BYTE 1
DC H'0C30' BYTE 0
TAB2 DC D'86' RELATIVE SQUARE POSITION TABLE
DC D'84'
DC D'82'
DC D'80'
DC D'07'
DC D'05'
DC D'03'
DC D'01'
KING DC B'01011010' KING'S CROWN
DC B'00111100'
DC B'00011000'
REDP DC B'00111100' RED PIECE
DC B'01111110'
DC B'01111110'
DC B'01111110'
DC B'00111100'
BLKP DC B'00111100' BLACK PIECE
DC B'01000010'
DC B'01000010'
DC B'01000010'
DC B'00111100'
POIN DC B'00001100'
DC B'00000110'
DC B'00000011'
DC B'00000001'
*******************************************************************
*
* SKILL LEVEL TEXT TABLE
*
********************************************************************
SKL DC H'3119' CH
DC H'1313' OO
DC H'210B' SE
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'150B' KE
DC H'0500' Y-
DC H'00' -
DC H'00' -
DC H'0713' TO
DC H'2900' M-
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'07' T
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DICK DC H'1F01' DI
DC H'3115' CK
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'1F' D
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
HARY DC H'1911' HA
DC H'0909' RR
DC H'0500' Y-
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'19' H
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
*
* 64 BYTES TABLE FOR
* CHOOSE SKILL LEVEL
* INPUT MODE J/K
*
INJK DC H'012B' IN
DC H'2503' PU
DC H'0700' T-
DC H'00' -
DC H'00' -
DC H'2913' MO
DC H'1F0B' DE
DC H'00' -
DC H'35' ?
DC H'00' -
DC H'00' -
KBRD DC H'150B' KE
DC H'052D' YB
DC H'1311' OA
DC H'091F' RD
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'15' K
DC H'00' -
DC H'00' -
DC H'1713' JO
DC H'0521' YS
DC H'0701' TI
DC H'3115' CK
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'00' -
DC H'17' J
DC H'00' -
DC H'00' -
*
* END OF zINPUT MGDE TABLE
* 48 BYTES
*Initial moves for black
BLKM DC H'4' Number of valid entries
DC B'11110000' A byte
DC H'0100' with byte info (byte 1 RFN moves)
DC B'11100000'
DC H'0101'
DC H'00'
*Initial moves for red
REDM DC H'4' Number of valid entries
DC B'00000111'
DC H'0210'
DC B'00001111'
DC H'0211'
DC H'00'
*
ORG H'1980'
*
JOYI LR K,P
LR A,HU SAVE POT# IN SP20
LISU 2
LISL 0
LR I,A
LIS 1 SET PORT 0
JOY8 DS HU
BM JOY7
SL 1
BR JOY8
JOY7 OUTS 0
LIS 3 SAVE YCUR+3 INTO SP21
DCI YCUR
AM
LR S,A
DCI YINT SET YINT TO YCUR+3
ST
LI JOY1: SET SMI VECTOR
OUTS H'C'
LI JOY1.
OUTS H'D'
LIS 1 ENABLE SMI
OUTS H'E'
EI ENABLE CPU INT
LIS INT SET INT BIT IN PCOM
DCI PCOM
LR H,DC SAVE ADDRESS
XM
LR DC,H RECOVER ADDRESS
ST
DCI COM AND IN COM REG
ST
BR * WAIT
*
YCUR EQU H'08F8'
YINT EQU H'08F0'
PCOM EQU CMRG
PRIS EQU H'0FDE'
FRZ EQU H'2'
XFRZ EQU H'08F8'
YFRZ EQU H'08F9'
INT EQU H'8'
JOY1 LI H'80' ENABLE JOYSTICKS
DCI PRIS DCO TO PORT 1 SAVE
LR H,DC SAVE IN H REGISTER
LM GET CURRENT SAVED VALUE
OI H'80' JOYSTICK BIT ON
LR DC,H RECOVER ADDRESS
ST RESET SAVE VALUE
OUTS 1
LI JOY2. SET SMI VECTOR
OUTS H'D'
LIS H'A' SET FRZ AND CLEAR INT BITS
DCI PCOM
LR Q,DC
XM
LR DC,Q
ST IN PCOM
DCI COM
ST AND IN COM REG
EI ENABLE CPU INT
BR * WAIT
JOY2 LR DC,H RECOVER PRIS ADDRESS
LM RECOVER VALUE
NI H'7F' JOYSTICKS OFF
LR DC,H RECOVER ADDRESS
ST RESET VALUE
OUTS 1 AND DISABLE JOYSTICKS AT UM1
CLR CLEAR ACC
OUTS H'E' DISABLE SMI
LR QU,A ZERO Q
LR QL,A
LR HU,A SET H=NUMBER OF DOTS/LINE
LI 228
LR HL,A
LR A,S COMPUTE NUMBER OF LINES
COM
INC
DCI YFRZ
AM
LR S,A INTO SP21
PI AD MULTIPLY- RESULT INTO Q
DS S
BNZ *-4
DCI XFRZ ADD XFRZ
LM
LR HL,A
PI AD
LI 38 SUBTRACT 38
LR HL,A
PI SU
LR A,QU SAVE RESULT IN SP21,22
LR I,A
LR A,QL
LR D,A
LR A,D INDEX INTO THE MAX-MIN VALUES
LR A,I FOR THE POT
SL 1
SL 1
DCI JOYT
ADC
LM LOAD MAXIMUM INTO H
LR HU,A
LM
LR HL,A
PI SU IS MAX<=READING?
BNC JOY3
LI -2 YES- RESET MAX
ADC
LR A,I
ST
LR A,D
ST
BR JOY6 AND RETURN MAX
JOY3 LR A,I SET READING INTO Q
LR QU,A
LR A,D
LR QL,A
LM LOAD MINIMUM INTO H
LR HU,A
LM
LR HL,A
PI SU IS MIN<=READING?
BC JOY4
LI -2 NO- RESET MIN
ADC
LR A,I
ST
LR A,D
ST
CLR AND RETURN 0
BR JOYB
JOY4 LR A,QU SAVE READING-MIN IN SP21,22
LR I,A
LR A,QL
LR D,A
LI -4 LOAD MAX INTO Q
ADC
LM
LR QU,A
LM
LR QL,A
PI AD COMPUTE MAX-MIN
DCI H'535'
LR H,DC
PI SU IS 535<=RANGE?
BC *+5
LIS 8 NO- SET FACTOR=8
BR JOY5
LIS H'1'
LR HU,A
LIS H'A'
LR HL,A
PI SU IS 801<=RANGE?
BC *+5
LIS 6 NO- SET FACTOR=6
BR JOY5
LIS H'1'
LR HU,A
LIS H'C'
LR HL,A
PI SU IS 1069<=RANGE?
BC *+5
LIS 4 NO- SET FACTOR=4
BR JOY5
DCI 1601-1069
LR H,DC
PI SU IS 1601<=RANGE?
LIS 3 NO- SET FACTOR=3
BNC JOY5
LIS 2 YES- SET FACTOR=2
JOY5 LISL 0 SAVE FACTOR IN SP20
LR I,A
CLR ZERO Q
LR QU,A
LR QL,A
LR A,I SET OFFSET READING IN H
LR HU,A
LR A,D
LR HL,A
LISL 0
PI AD MULTIPLY BY FACTOR
DS S
BNZ *-4
LR A,QU IS RESULT<256*16?
SR 4
BNZ JOY6 NO- GO RETURN 199
LR A,QU DIVIDE BY 16
SL 4
LR S,A
LR A,QL
SR 4
XS S
CI 199 IS RESULT<=199?
BC *+4
JOY6 LI 199 NO- SET IT TO 199
JOYB LR S,A SAVE IT IN SP21
LIS FRZ CLEAR FRZ BIT
DCI PCOM IN PCOM
LR H,DC SAVE ADDRESS
XM
LR DC,H RECOVER SAME
ST
DCI COM AND IN COM REG
ST
LR A,D RETURN WITH VALUE IN AC
PK
********************
* SUBTRACT H FROM Q
* CARRY SET ON Q+COM(H)+1=10000+(Q-H)
* CARRY THUS SET IFF H<=Q
SU LR A,HU
COM
LR HU,A
LR A,HL
COM COMPLEMENT...
INC
LR HL,A
LR A,HU
LNK
LR HU,A AND INCREMENT H
LR A,QU PREPARE FOR RETURN WITH QU IN AC
BC AD1 IF CARRY, H=0, SO GO RETURN
* WITH CARRY SET
*
* ADD H TO Q
AD LR A,QL
AS HL
LR QL,A
LR A,QU
LNK
BC AD0 IF CARRY, QU+LNK=100, SO GO LOAD WITH
AS HU HU AND RETURN WITH CARRY SET
LR QU,A ADD TO Q
AD1 POP
AD0 LR A,HU
LR QU,A
POP
END